package com.wzy.authority.mapper;

import com.wzy.authority.domain.SysRolePermission;
import com.wzy.authority.domain.SysRoleUser;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface SysRoleUserMapper {

    /**
     * 插入数据
     * @param record
     * @return
     */
    int insert(SysRoleUser record);


    /**
     * 查询根据用户id
     * @param userId
     * @return
     */
    @Select("select *  from sys_role_user where userId = #{userId}")
    SysRoleUser selectRoleUserByUserId(Integer userId);


    /**
     * 修改用户 - 权限表
     * @param sysRoleUser
     * @return
     */
    Integer updateByUserId(SysRoleUser sysRoleUser);


    /**
     * 删除用户 - 权限关联表中的数据
     * @param userId
     */
    @Delete("delete from sys_role_user where userId = #{userId}")
    void deleteByUserId(Integer userId);


    /**
     * 根据角色id查询数据  用户-角色链接表
     * @param roleId
     * @return
     */
    @Select("select *  from sys_role_user where roleId = #{roleId}")
    List<SysRolePermission> selectRoleUserByRoleId(Integer roleId);
}